package cn.com.dcsgo.controller;

import cn.com.dcsgo.model.Result;
import cn.com.dcsgo.service.FileService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 后台系统文件管理相关接口
 * OSS使用可参考：<a href="https://developer.aliyun.com/article/1227235">...</a>
 *
 * @author Dcsgo
 * @since 2025/9/28 15:50
 */
@Slf4j
@RestController
@RequestMapping("admin/file")
@Tag(name = "后台系统文件管理相关接口", description = "使用阿里云OSS进行文件存储")
public class FileController {
    @Resource
    private FileService fileService;

    @PostMapping("upload/element")
    @Operation(summary = "上传文件",description = "返回的数据为上传文件的访问URL")
    public Result<String> upload(MultipartFile file) {
        return Result.success(fileService.upload(file));
    }
}
